using System.Collections.Generic;
using LitJson;
using UnityEngine;

namespace abilities.targets
{
    public enum TargetUnitSide
    {
        ALLY = 0,
        ENEMY = 1
    }

    public enum TargetUnitType
    {
        Hero,Pet
    }

    public enum DamageType
    {
        AOE,
        AREA,
        SINGLE
    }

    /**目标选择器。实现的例子是在区域内的单位(例如圆)*/
    public class Target
    {
        public static Target TargetFromJson(JsonData value)
        {
            if (value.GetJsonType() == JsonType.None)
                return null;

            Target result = null;

            string type = (string)value["type"];

            if ("Self" == type)
            {
                result = new TargetSelf();
            }
            else if ("Around" == type)
            {
                result = new TargetsAround();
            }
            else if ("Current" == type)
            {
                result = new TargetCurrent();
            }
            else if ("CurrOrNearest" == type)
            {
                result = new TargetCurrentOrNearest();
            }

            if (result != null)
            {
                result.FromJson(value);
            }
            else
            {
                Debug.Log("Unknown target type");
            }

            return result;
        }
        
        public virtual bool FromJson(JsonData value)
        {
            return false;
        }

        public virtual List<TargetObject> GetTargets(AbilityContext context)
        {
            return null;
        }
    }
}